﻿
Imports LibMultiPlug.Core.Plugins.Interfaces
Imports LibMultiPlug.Core.Plugins

Namespace Implementation.Funktionen.Buchungen

    Public Class BuchungDetailPlug
        Implements IPlugChildV1


        Private Const C_NAME As String = "Neue Buchung"
        Private Const C_TRANSACTION As String = "book"
        Private Const C_DESCRIPTION As String = ""
        Private Const C_PLUG_KEY As String = "book_detail_plug"

        Private _environment As PluginEnvironment

        Public Sub New(ByVal environment As PluginEnvironment)
            _environment = environment
        End Sub

#Region "IPlugChildV1 Implementation"

        Public Sub Action() Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Action
            ShowForm(Nothing)
        End Sub

        Public ReadOnly Property ActionText As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.ActionText
            Get
                Return C_NAME
            End Get
        End Property

        Public ReadOnly Property Children As System.Collections.Generic.List(Of LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Children
            Get
                Return Nothing
            End Get
        End Property

        Public ReadOnly Property Description As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Description
            Get
                Return C_DESCRIPTION
            End Get
        End Property

        Public ReadOnly Property Icon As System.Drawing.Bitmap Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Icon
            Get
                Return My.Resources.application_form_add
            End Get
        End Property

        Public ReadOnly Property Name As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Name
            Get
                Return C_NAME
            End Get
        End Property

        Public Sub StartTransaction(ByVal args() As String) Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.StartTransaction
            ShowForm(args)
        End Sub

        Public ReadOnly Property ToolStrip As System.Windows.Forms.ToolStrip Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.ToolStrip
            Get

            End Get
        End Property

        Public ReadOnly Property Transaktion As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Transaktion
            Get
                Return C_TRANSACTION
            End Get
        End Property

#End Region

        Private Sub ShowForm(ByVal args() As String)

            Dim id As Integer
            Dim bdf As New BuchungDetailForm

            If args IsNot Nothing AndAlso args.Length > 0 AndAlso Integer.TryParse(args(0), id) Then
                bdf.Show(_environment.MainDockPanel, id)
            Else
                bdf.Show(_environment.MainDockPanel)
            End If

        End Sub

        Public ReadOnly Property Key As String Implements LibMultiPlug.Core.Plugins.Interfaces.IPlugChildV1.Key
            Get
                Return C_PLUG_KEY
            End Get
        End Property
    End Class

End Namespace